package com.west_traveler.application;

import android.app.Application;
import android.os.StrictMode;
import android.util.Log;

import com.west_traveler.inteface.HttpService;
import com.west_traveler.inteface.LiveHttpService;
import com.west_traveler.inteface.WelcomeHttpService;
import com.west_traveler.ximalayafm.BuildConfig;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Description:
 * created at 2016/12/2 11:03
 *
 * @author: 黄昌友
 */

public class BaseApplication extends Application {

    private HttpService service;
    private LiveHttpService liveHttpService;
    private WelcomeHttpService welcomeHttpService;

    public static String lastUrl = "";
    public static boolean serviceRunning = false;

    @Override
    public void onCreate() {
        super.onCreate();
//        if (BuildConfig.DEBUG) {
//            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
//                    .detectAll()
//                    .penaltyLog()
//                    .penaltyDialog()
//                    .penaltyDeath()
//                    .build());
//            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
//                    .detectAll()
//                    .penaltyLog()
//                    .penaltyDeath()
//                    .build());
//            Log.i("16200","测试版本");
//        }
        service = new Retrofit.Builder()
                .baseUrl("http://mobile.ximalaya.com/")
                .addConverterFactory(GsonConverterFactory.create())
                .build()
                .create(HttpService.class);

        //获取发现广播界面数据接口
        liveHttpService = new Retrofit.Builder()
                .baseUrl("http://live.ximalaya.com/")
                .addConverterFactory(GsonConverterFactory.create())
                .build()
                .create(LiveHttpService.class);

        //欢迎界面数据接口
        welcomeHttpService = new Retrofit.Builder()
                .baseUrl("http://adse.ximalaya.com/")
                .addConverterFactory(GsonConverterFactory.create())
                .build()
                .create(WelcomeHttpService.class);
    }

    public HttpService getService() {
        return service;
    }

    public LiveHttpService getLiveHttpService() {
        return liveHttpService;
    }

    public WelcomeHttpService getWelcomeHttpService() {
        return welcomeHttpService;
    }

}
